/**
 * http请求api
 */

import { del, get, post, put } from "@src/utils/request";
import { CustomRequestConfig } from "@src/utils/request/axiosIns";


// 动态发布
export const createSquare = (data) => {
    return post("square/issues/", data);
};

// 动态发布
export const createIssue = (data) => {
    return post("square/issues/publishing/", data);
};

// 动态列表查询
export const getSquareList = (data, optinos) => {
    return get("square/issues/", data, optinos);
};

// 动态详情查询
export const getSquarePostDetail = (id, options) => {
    return get(`square/issues/${id}`, {}, options);
};

// 查询某个用户信息
export const getUserInfoById = (id) => {
    return get(`/user/profile/${id}/`);
};

// 查询当前用户
export const getCurrentUserInfo = (options: CustomRequestConfig) => {
    return get("/user/profile/current_profile/", {}, options);
};

// 更新用户信息
export const updateUserInfo = (id, data) => {
    return put(`/user/profile/${id}/`, data);
};

// 对某条状态点赞
export const likeIssue = (id) => {
    return post(`/square/issues/${id}/thumbs_up/`);
};


// 关注某人
export const followUser = (id) => {
    return post(`/user/user/${id}/follow/`);
};



/** ======comment======== */

// 对动态发表评论
export const commentIssue = (id, data) => {
    return post(`/square/issues/${id}/comment/`, data);
};
// 回复某条评论
export const commentComment = (commontId, issues_id, data) => {
    return post(`/business/comment/${commontId}/comment/`, {
        issues_id,
        ...data
    });
};
// 删除动态的评论
export const deleteComment = (commentId) => {
    return del(`/square/issues/${commentId}/comment/`);
};

// 获取一级评论
export const getIssueComment = (issueId, pagination = {}) => {
    return get("/business/comment/by_content_type/", {
        content_type: "issues",
        content_id: issueId,
        ...pagination
    });
};

// 获取二级评论
export const getCommentComment = (commentId, pagination = {}) => {
    return get(`/business/comment/${commentId}/comment/`, {
        ...pagination
    });
};

// 点赞某条评论
export const likeOneComment = (commentId, issuesId) => {
    return post(`/business/comment/${commentId}/thumbs_up/`, {
        issues_id: issuesId
    });
};